$path = parse_url($url, PHP_URL_PATH); $pathFragments = explode('/', $path); $end = end($pathFragments);